﻿#ifndef TRANSDIALOG_H
#define TRANSDIALOG_H

#include <QDialog>

namespace Ui {
class TransDialog;
}

class QNetworkAccessManager;
class QNetworkReply;

class TransDialog : public QDialog
{
    Q_OBJECT

public:
    explicit TransDialog(QWidget *parent = nullptr);
    ~TransDialog();

    void setText(const QString &newText);

    void accept();

private slots:
    void on_pbt_extract_clicked();

    void on_pbt_trans_clicked();

    void replyFinished(QNetworkReply *reply);

private:
    Ui::TransDialog *ui;

    enum DataRole {
        StartIndexRole = Qt::UserRole,
        LengthRole = Qt::UserRole + 1,
    };

    QString m_text;

    QNetworkAccessManager * m_Manager;

    int current_row = 0;

    void trans_one(const QString &cText);

    void delay_ms(int ms);    // 延迟
};

#endif // TRANSDIALOG_H
